//


#import "MB_AddDietCollectionViewCell.h"

//
@interface MB_AddDietCollectionViewCell ()<UITextViewDelegate>
/** Description*/
@property (nonatomic, strong) UILabel *textLabel;
/** Description*/
@property (nonatomic, strong) UITextView *textView;

@end

@implementation MB_AddDietCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        [self setUpView];
    }
    return self;
}
//
- (void)setUpView {
    
    self.textLabel = ({
        UILabel *label = [[UILabel alloc]init];
        label.textColor = rgba(90, 90, 90, 1);
        label.font = FontPFRegular(kRHeight(15));
        label.text = @"早餐";
        [self.contentView addSubview:label];
        label;
    });
    self.textView = ({
        UITextView *view = [[UITextView alloc]init];
        view.textColor = [UIColor blackColor];
        view.font = FontPFRegular(kRWidth(16));
        view.delegate = self;
        [self.contentView addSubview:view];
        view;
    });
    
    [self.textLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_offset(kRHeight(10));
        make.left.mas_offset(kRWidth(10));
        make.height.mas_equalTo(kRHeight(20));
    }];
    [self.textView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.textLabel.mas_bottom).offset(kRHeight(5));
        make.left.mas_offset(kRWidth(10));
        make.right.mas_offset(-kRWidth(10));
        make.height.mas_equalTo(self.contentView.frame.size.height - kRHeight(40));
    }];
    
}
//
- (void)textViewDidChange:(UITextView *)textView {
    if ([self.delegate respondsToSelector:@selector(senderDietCell:text:)]) {
        [self.delegate senderDietCell:self text:textView.text];
    }
}
//MARK:
- (void)setModel:(DietData *)model {
    _model = model;
    //
    switch (_indexx) {
        case 0:
            self.textLabel.text = @"Breakfast";
            self.textView.text = model.breakfast;
            break;
        case 1:
            self.textLabel.text = @"Chinese Meal";
            self.textView.text = model.chineseMeal;
            break;
        case 2:
            self.textLabel.text = @"Dinner";
            self.textView.text = model.dinner;
            break;
        case 3:
            self.textLabel.text = @"Other";
            self.textView.text = model.other;
            break;
        default:
            break;
    }
}


@end
